package com.tvunetworks.center.user.mapper;

import com.tvunetworks.center.user.model.UserFeature;
import com.tvunetworks.center.user.model.UserRole;
import com.tvunetworks.center.user.model.vo.UserFeatureVo;
import com.tvunetworks.center.user.model.vo.UserFeatureWithRole;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
/**
 * @program:
 * @description:
 * @author HenryChen
 * @create: 5/29/2019 12:17 PM
 **/
public interface UserFeatureMapper extends Mapper<UserFeature> {
    /**
     *
     * @return List
     */
    List<UserRole> listUserRole();

    /**
     * 查询用户所有feature，不包括Admin自动拥有的feature
     * @param userId userId
     * @return List
     */
    List<UserFeatureVo> listUserFeatureWithoutAdminAutoOwn(String userId);

    /**
     * 查询用户所有feature
     * @param userId userId
     * @return List
     */
    List<UserFeatureVo> listUserFeature(String userId);

    /**
     * 查询用户所有 AdminAutoOwn feature
     * @param userId userId
     * @return List
     */
    List<UserFeatureVo> listAdminAutoOwnUserFeature(String userId);

    /**
     * 查询用户所有 非AdminAutoOwn feature
     * @param userId userId
     * @return List
     */
    List<UserFeatureVo> listNotAdminAutoOwnUserFeature(String userId);


    /**
     * 查询admin用户创建的user用户中 某个feature时enable为UserFeature
     * @param userId userId
     * @param featureId featureId
     * @return List
     */
    List<UserFeature> listAdminSonEnableFeature(@Param("userId") String userId, @Param("featureId") String featureId);

    /**
     * UserFeature修改 同步到UserRole
     * @param userId userId
     * @param feature feature
     * @param enable enable
     */
    void updateUserRole(String userId, String feature, Integer enable);

    /**
     * group by feature 查询UserRole表中所有的feature
     * @return List
     */
    @Deprecated
    List<String> listUserRoleFeature();

    /**
     * 根据feature 查询UserRole表中value=1的结果
     * @param feature feature
     * @return List
     */
    @Deprecated
    List<UserFeatureWithRole> listUserFeatureWithRole(String feature);


    /**
     * 列出用户可以为孩子提供Feature中的Menu列表 中的featureId列表
     * 用于在创建用户，或者修改用户权限的时候，查询自己拥有的所有feature-menu，返回结果显示框供勾选
     * @param userId userId
     * @return List
     */
    List<String> listUserMenuFeatureIds(@Param("userId") String userId);

    /**
     * 列出用户可以为孩子提供Feature中的非Menu列表非adminAutoOwn 中的featureId列表
     * 用于在创建用户，或者修改用户权限的时候，查询自己拥有的所有feature，返回结果显示框供勾选
     * @param userId userId
     * @return List
     */
    List<String> listUserNotMenuNotAdminAutoOwnFeatureIds(@Param("userId") String userId);

    /**
     * 列出用户拥有的所有featureIds，只包含UserFeature里面enable的结果
     * @param userId userId
     * @return List
     */
    List<String> listUserEnableFeatureIds(@Param("userId") String userId);


    /**
     * 列出用户在 UserRole 表里拥有的所有feature
     * @param userId userId
     * @return List
     */
    @Deprecated
    List<String> listUserEnableRole(String userId);

    /**
     * 列出用户在 UserRole 表里不拥有的所有feature
     * @param userId userId
     * @return List
     */
    @Deprecated
    List<String> listUserDisableRole(String userId);

    /**
     * 根据featureId和userId查找UserFeature
     * @param userId userId
     * @param featureId featureId
     * @return UserFeature
     */
    UserFeature getUserFeatureByFeatureIdAndUserId(@Param("userId") String userId, @Param("featureId") String featureId);

    /**
     * 根据featureId查询用户id
     * @param featureId featureId
     * @return List
     */
    List<String> listUserByFeature(@Param("featureId") String featureId);

    /**
     * 根据权限名字获取权限的feature_id
     * @param enName feature的英文名字
     * @return featuerId
     */
    String getFeatureIdByName(@Param("enName") String enName );
}
